﻿// =================================================================== 
// 数据实体层(GDIT.Model)实体映射
//====================================================================
// 文件：Mtb_PicInfo.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
// 引用DevExpress.Xpo程序集
// 程序集介绍：图片信息实体类
// ===================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;

namespace GDIT.Model
{
    public class Mtb_PicInfo : PersistentClass
    {
            public Mtb_PicInfo()
            : base()
        {
            this.Modified = false;
        }

            public Mtb_PicInfo(Session theSession)
            : base(theSession)
        {
            this.Modified = false;
        }

        private string _picPath = string.Empty;
        /// <summary>
        /// 图片路径
        /// </summary>
        [DbType("varchar(256)")]
        public string PicPath
        {
            get { return _picPath; }
            set
            {
                if (_picPath != value)
                {
                    _picPath = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        /// <summary>
        /// 所属图片类型
        /// </summary>
        [Association("PicTypeInfos")]
        public Mtb_PicType PicType;


        private string _visible = string.Empty;
        /// <summary>
        /// 图片是否可见
        /// </summary>
        [DbType("varchar(2)")]
        public string Visible
        {
            get { return _visible; }
            set
            {
                if (_visible != value)
                {
                    _visible = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _alt = string.Empty;
        /// <summary>
        /// 图片提示
        /// </summary>
        [DbType("varchar(256)")]
        public string Alt
        {
            get { return _alt; }
            set
            {
                if (_alt != value)
                {
                    _alt = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _linkaddress = string.Empty;
        /// <summary>
        /// 图片链接地址
        /// </summary>
        [DbType("varchar(256)")]
        public string LinkAddress
        {
            get { return _linkaddress; }
            set
            {
                if (_linkaddress != value)
                {
                    _linkaddress = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private int _sn = 0;
        /// <summary>
        /// 顺序号
        /// </summary>
        [DbType("int")]
        public int Sn
        {
            get { return _sn; }
            set
            {
                if (_sn != value)
                {
                    _sn = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        /// <summary>
        /// 防止编辑后马上保存
        /// </summary>
        protected override void EndEdit()
        {
            return;
        }

        /// <summary>
        /// 检验数据
        /// </summary>
        /// <returns></returns>
        public override string GetDataError()
        {
            if (this._picPath.Trim().Length == 0) { return string.Format("图片路径不能为空"); }
            if (this._linkaddress.Trim().Length == 0) { return string.Format("图片链接地址不能为空"); }
            if (this._picPath.Trim().Length == 0) { return string.Format("图片提示不能为空"); }
            return "";
        }
    }
}
